#define _CRT_SECURE_NO_WARNINGS 1

void reverse(int* nums, int numsSize)
{
    int left = 0;
    int right = numsSize - 1;
    while (left < right)
    {
        int tmp = nums[left];
        nums[left] = nums[right];
        nums[right] = tmp;
        left++;
        right--;
    }
}

void rotate(int* nums, int numsSize, int k) {
    int times = k % numsSize;
    reverse(nums, numsSize - times);
    reverse(nums + numsSize - times, times);
    reverse(nums, numsSize);
}